#include<iostream>
#include<string.h>
using namespace std;
#define Max 100
int cmmdcs(int a,int b)
{
while(a!=b)
{
if(a>b)
a-=b;
else
b-=a;
}
return a;
}
int cmmdc(int a[],int n)
{

int i,cm=cmmdcs(a[0],a[1]);
for(i=0;i<n;i++)
   cm=cmmdcs(cm,a[i]);
return cm;

}
int main()
{
int a,b,n,i, nr[Max];
cout<<"Introduceti cele doua numere pentru care doriti sa calculati cmmdc:";
cin>>a>>b;
cout<<"\ncmmdc este :"<<cmmdcs(a,b);
cout<<"\nIntroduceti numarul de elemnte:"; cin>>n;
cout<<"\nIntroduceti elementele:";
for(i=0;i<n;i++)
{  cout<<"\nnr["<<i<<"]=";
cin>>nr[i];
}
cout<<"\ncmmdc al sirului este:"<<cmmdc(nr,n);
cout<<endl;
return 0;
}
  


